package com.zb.validation.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;


/**
 * 在控制层实现Validation
 *
 * @author ZB
 * @version 1.0
 * @since 1.0
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/demo-1")
public class Demo1Controller {

    /**
     * 在参数上做校验，基本类型
     * @param name 名称
     *
     * @return
     */
    @GetMapping("/query-1")

    public HttpStatus query1(@NotBlank(message = "不能为空") String name) {
        log.info("name is {}", name);
        return HttpStatus.OK;
    }

}
